package com.eye.catcher.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eye.catcher.entity.TSysDaUser;
import com.eye.catcher.system.user.param.UserDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author huzhiwei
 * @since 2022-02-08
 */
@Mapper
public interface TSysDaUserMapper extends BaseMapper<TSysDaUser> {
    String querySql = " SELECT  u.*,ur.roleIds,ur.roleNames " +
            " FROM t_sys_da_user u " +
            " LEFT JOIN vw_user_rolelist ur on u.id = ur.id ";

    String wrapperSql = " select * from (" + querySql + ") as q ${ew.customSqlSegment}";
    String counrWrapperSql = " select count(1) from (" + querySql + ") as q ${ew.customSqlSegment}";
    public abstract UserDto getUserInfoById(String userId);

    @Select(wrapperSql)
    public abstract IPage<TSysDaUser> page(Page<TSysDaUser> page,@Param("ew") QueryWrapper<TSysDaUser> wrapper);

    @Select(counrWrapperSql)
    public abstract long count(@Param("ew") QueryWrapper<TSysDaUser> wrapper);
}
